<template>
	<view>
		<scroll-view scroll-y="true" :style="{height:windowHeight}">
			<view class="">
				<view style="background-color: #ffffff;padding-left: 32rpx;padding-right: 32rpx;">
					<view style="height: 108rpx;display: flex;align-items: center;">
						<text class="title">客户名称<text class="star">*</text></text>
						<input type="text" placeholder="请填写客户名称" class="placeholder-view" v-model="name" >
					</view>
					<view class="line"></view>
					<view style="height: 108rpx;display: flex;align-items: center;">
						<text class="title">客户简称</text>
						<input type="text" placeholder="请填写客户简称" class="placeholder-view" v-model="shortName" >
					</view>
					<view class="line"></view>
					<view style="height: 108rpx;display: flex;align-items: center;">
						<text class="title">客户类型<text class="star">*</text></text>

						<view class="xuanze" @click="chooseCustomType">
							<text :class="customTypeValue==-1 ? 'xuanze-t':'xuanze-tt'">{{customType}}</text>
							<image src="../../../../static/phone/quxuanze.png" class="xuanze-i"></image>
						</view>

					</view>
					<view class="line"></view>
					<view style="height: 108rpx;display: flex;align-items: center;">
						<text class="title">联系地址<text class="star">*</text></text>
						<input type="text"  class="placeholder-view" placeholder="请填写联系地址" v-model="address">
						<!-- <picker mode="region" @change="bindRegionChange" style="margin-left: auto;">
							<view class="xuanze">
								<text :class="areaValue==-1 ? 'xuanze-t':'xuanze-tt'">{{area}}</text>
								<image src="../../../../static/phone/quxuanze.png" class="xuanze-i"></image>
							</view>
						</picker> -->

					</view>
<!-- 					<view class="line"></view>
					<view style="height: 108rpx;display: flex;align-items: center;">
						<input type="text" style="width: 686rpx;" class="placeholder-view" placeholder="请填写详细地址" v-model="address">
					</view> -->
					<view class="line"></view>
					<view style="height: 108rpx;display: flex;align-items: center;">
						<text class="title">绑定用户<text class="star">*</text></text>
						<input type="text" placeholder="请输入用户手机号" class="placeholder-view" @input="searchCustomer" v-model="keywordCustomer">
					</view>
					
					<scroll-view  scroll-y="true" class="laywer-sel-popup" v-if="searchCustomerList.length>0">
						<view v-for="(item,index) in searchCustomerList" :key="index" @click="clickCustomer(item)" 
						style="height: 80rpx;display: flex;align-items: center;margin-left: 32rpx;">
							<image :src="item.account.avatarPic"
								v-if="item.account.avatarPic!=null && item.account.avatarPic!=undefined"
								style="width: 40rpx;height: 40rpx;margin-left: 8rpx;border-radius: 40rpx;"></image>
							
							<image src="../../../../static/phone/moren.png"
								v-if="item.account.avatarPic==null || item.account.avatarPic==undefined"
								style="width: 40rpx;height: 40rpx;margin-left: 8rpx;border-radius: 40rpx;"></image>
							<text class="listview-name" style="margin-left: 2rpx;">{{item.account.realName}}</text>
							<text class="listview-name" style="margin-left: 4rpx;">{{item.account.mobile}}</text>
							
						</view>
					</scroll-view>
					
			
					<view class="line"></view>

					<view v-if="dataList.length>0">
						<view v-for="(item,index) in dataList" :key="index" style="display: flex;align-items: center;">
							<view class="main_item" style="margin-left: 56rpx;">
								<image :src="item.account.avatarPic"
									v-if="item.account.avatarPic!=null && item.account.avatarPic!=undefined"
									style="width: 40rpx;height: 40rpx;margin-left: 8rpx;border-radius: 40rpx;"></image>
								<image src="../../../../static/phone/moren.png"
								v-if="item.account.avatarPic==null || item.account.avatarPic==undefined"
									style="width: 40rpx;height: 40rpx;margin-left: 8rpx;"></image>
								<text class="listview-name" style="margin-left: 2rpx;width: 100rpx;">{{item.account.realName}}</text>
								<text class="listview-name" style="margin-left: 4rpx;">{{item.account.mobile}}</text>
								<image @click="deleteBind(item,index)" src="../../../../static/phone/guanbi1.png"
									style="width: 32rpx;height: 32rpx;margin-left: auto;margin-right: 4rpx;"></image>
							</view>
							
							<text class="isauth">{{item.isAuthorize.desc==="是" ? '已授权':'未授权'}}</text>
							
							<text class="shuline"></text>
							
							<text class="isauth2" @click="toAuth(index)">{{item.isAuthorize.desc==="是" ? '取消授权':'授权'}}</text>

						</view>
					</view>

					<view class="line" style="margin-top: 18rpx;" v-if="dataList.length>0"></view>
					
				
					<view style="height: 108rpx;display: flex;align-items: center;">
						<text class="title">常用律师</text>
						<input type="text" placeholder="请输入律师姓名/手机号/工作组" class="placeholder-view" @input="searchLawyer" v-model="keywordLawyer">
					</view>
					
					
					<scroll-view  scroll-y="true" class="laywer-sel-popup" v-if="searchList.length>0">
						<view v-for="(item,index) in searchList" :key="index" @click="clickLawyer(item)" 
						style="height: 80rpx;display: flex;align-items: center;margin-left: 32rpx;">
							<image :src="item.account.avatarPic"
								v-if="item.account.avatarPic!=null && item.account.avatarPic!=undefined"
								style="width: 40rpx;height: 40rpx;margin-left: 8rpx;border-radius: 40rpx;"></image>
							
							<image src="../../../../static/phone/moren.png"
								v-if="item.account.avatarPic==null || item.account.avatarPic==undefined"
								style="width: 40rpx;height: 40rpx;margin-left: 8rpx;border-radius: 40rpx;"></image>
							<text class="listview-name" style="margin-left: 2rpx;">{{item.account.realName}}</text>
							<text class="listview-name" style="margin-left: 4rpx;">{{item.account.mobile}}</text>
							
						</view>
					</scroll-view>
					
					
					<view class="line" v-if="nameList.length>0"></view>

					<view class="listview" v-if="nameList.length>0">
						<view :class="index%2==1 ? 'main_item2':'main_item'" v-for="(item,index) in nameList">
							<image :src="item.account.avatarPic"
								v-if="item.account.avatarPic!=null && item.account.avatarPic!=undefined"
								style="width: 40rpx;height: 40rpx;margin-left: 8rpx;border-radius: 40rpx;"></image>
								
							<image src="../../../../static/phone/moren.png"
									v-if="item.account.avatarPic==null || item.account.avatarPic==undefined"
								style="width: 40rpx;height: 40rpx;margin-left: 8rpx;"></image>
							<text class="listview-name" style="margin-left: 2rpx;width: 100rpx;">{{item.account.realName}}</text>
							<text class="listview-name" style="margin-left: 4rpx;">{{item.account.mobile}}</text>
							<image @click="deleteLayer(item,index)" src="../../../../static/phone/guanbi1.png"
								style="width: 32rpx;height: 32rpx;margin-left: auto;margin-right: 4rpx;"></image>
						</view>

					</view>

				</view>
				<view style="margin-top:24rpx;background-color: #ffffff;padding-left: 32rpx;padding-right: 32rpx;">
					<view style="height: 108rpx;display: flex;align-items: center;">
						<text class="title">联系信息</text>
						<view style="margin-left: auto;display: flex;align-items: center;" @click="openClose">
							<text class="open-close">{{linkMsg? '收起':'展开'}}</text>
							<image :src="linkMsg ? zhankai:shouqi"
								style="margin-left: 5rpx;width: 24rpx;height: 24rpx;"></image>
						</view>
					</view>

					<view class="" v-if="linkMsg">
						<view class="line"></view>
						<view style="height: 108rpx;display: flex;align-items: center;">
							<text class="title">电话</text>
							<input type="text" placeholder="请填写电话" class="placeholder-view" v-model="phoneNumber">
						</view>
						<view class="line"></view>
						<view style="height: 108rpx;display: flex;align-items: center;">
							<text class="title">传真</text>
							<input type="text" placeholder="请填写传真" class="placeholder-view" v-model="faxNumber">
						</view>
						<view class="line"></view>
						<view style="height: 108rpx;display: flex;align-items: center;">
							<text class="title">邮箱</text>
							<input type="text" placeholder="请填写邮箱" class="placeholder-view" v-model="email"> 
						</view>
						<view class="line"></view>
						<view style="height: 108rpx;display: flex;align-items: center;">
							<text class="title">网站</text>
							<input type="text" placeholder="请填写网站" class="placeholder-view" v-model="website">
						</view>
						<view class="line"></view>
						<view style="height: 108rpx;display: flex;align-items: center;">
							<text class="title">联系人</text>
							<input type="text" placeholder="请填写联系人" class="placeholder-view" v-model="contactName">
						</view>
						<!-- <view class="line"></view> -->
						

					</view>
				</view>
				
				<view style="margin-top:24rpx;background-color: #ffffff;padding-left: 32rpx;padding-right: 32rpx;">
					<view style="height: 108rpx;display: flex;align-items: center;">
						<text class="title">所在地</text>
						<input type="text" placeholder="请填写所在地" class="placeholder-view" v-model="domicile">
					</view>
				</view>

				<view style="margin-top:24rpx;background-color: #ffffff;padding-left: 32rpx;padding-right: 32rpx;">
					<view style="height: 108rpx;display: flex;align-items: center;">
						<text class="title">开票信息</text>
						<view style="margin-left: auto;display: flex;align-items: center;" @click="openCloseKp">
							<text class="open-close">{{kpMsg? '收起':'展开'}}</text>
							<image :src="kpMsg ? zhankai:shouqi" style="margin-left: 5rpx;width: 24rpx;height: 24rpx;">
							</image>
						</view>
					</view>

					<view class="" v-if="kpMsg">
						<view class="line"></view>
						<view style="height: 108rpx;display: flex;align-items: center;">
							<text class="title">单位名称</text>
							<input type="text" placeholder="请填写单位名称" class="placeholder-view" v-model="companyName">
						</view>
						<view class="line"></view>
						<view style="height: 108rpx;display: flex;align-items: center;">
							<text class="title">纳税人识别号</text>
							<input type="text" placeholder="请填写纳税人识别号" class="placeholder-view" v-model="taxNo">
						</view>
						<view class="line"></view>
						<view style="height: 108rpx;display: flex;align-items: center;">
							<text class="title">开户银行</text>
							<input type="text" placeholder="请填写开户银行" class="placeholder-view" v-model="bankName">
						</view>
						<view class="line"></view>
						<view style="height: 108rpx;display: flex;align-items: center;">
							<text class="title">银行账号</text>
							<input type="text" placeholder="请填写银行账号" class="placeholder-view" v-model="bankNo">
						</view>
						<view class="line"></view>
						<view style="height: 108rpx;display: flex;align-items: center;">
							<text class="title">注册地址</text>
							<input type="text" placeholder="请填写注册地址" class="placeholder-view" v-model="regAddress">
						</view>
						<view class="line"></view>
						<view style="height: 108rpx;display: flex;align-items: center;">
							<text class="title">注册电话</text>
							<input type="text" placeholder="请填写注册电话" class="placeholder-view" v-model="regPhone">
						</view>
						
					</view>
				</view>
				
				<view style="margin-top:24rpx;background-color: #ffffff;padding-left: 32rpx;padding-right: 32rpx;">
					<view style="height: 108rpx;display: flex;align-items: center;">
						<text class="title">权限类别</text>
						<view class="xuanze" @click="chooseEnrollType">
							<text :class="enrollTypeValue==-1 ? 'xuanze-t':'xuanze-tt'">{{enrollType}}</text>
							<image src="../../../../static/phone/quxuanze.png" class="xuanze-i"></image>
						</view>
					</view>
				</view>
				
				<view  style="margin-top:24rpx;background-color: #ffffff;padding-left: 32rpx;padding-right: 32rpx;">
					<view style="height: 108rpx;display: flex;align-items: center;">
						<text style="color: #666666;font-weight: 400;font-size: 28rpx;">以下信息客户不可见</text>
					</view>
					
					<view style="display: flex;align-items: center;padding-bottom: 34rpx;">
						<text class="title">组别标签</text>
					
						<view class="xuanze" @click="chooseTeamTag">
							<text :class="teamTagValue==-1 ? 'xuanze-t':'xuanze-tt'">{{teamTag}}</text>
							<image src="../../../../static/phone/quxuanze.png" class="xuanze-i"></image>
						</view>
					
					</view>
					<view class="line"></view>
					<view style="padding-top: 24rpx;padding-bottom: 28rpx;">
						<text class="title">客户备注</text>
					</view>
					
					<view class="textareaview"
					style="margin-bottom: 32rpx;">
						<textarea placeholder="请填写客户备注" 
							placeholder-style="color:#666666;font-size:28rpx" 
							class="textarea"
							
							v-model="remark"
						/>	
					</view>
					
					
					<view class="line"></view>
				</view>
			</view>
		</scroll-view>
		<view class="view-bottom">
			<view class="view-bottom-s">
				<view class="view-bottom-sl" @click="cancelIt">
					取消
				</view>
				<view class="view-bottom-sr" @click="saveIt">
					保存
				</view>
			</view>
			<!-- <view style="height: 68rpx;background: #ffffff;" v-if="needAdapt"> -->
			<!-- 苹果x及以上的安全距离 -->
			<!-- </view> -->
		</view>
		<common-choose v-if="showChoose" :chooseList="chooseList" :chooseResult="chooseResult" :chooseTag="chooseTag"
			@gotIt="gotIt"></common-choose>
			
			
		<!-- <view class="zhezhao" v-if="showSift">
			<view class="zhezhao-view-bottom">
				<scroll-view scroll-y="true" style="height: 644rpx;">
					<view class="zhezhao-title-view">
						组别标签
					</view>
					<view class="sift-listview">
						<view v-for="(item,index) in teamTagList" :key="index" 
						:class="item.sel ? 'sift-item-foucs':'sift-item'"  @click="siftTeamTag(index)">
							{{item.name}}
						</view>
					</view>
				</scroll-view>
				
				<view class="zhezhao-view-bottom-s">
					<view class="zhezhao-view-bottom-c" @click="cancelSift">
						重置
					</view>
					<view class="zhezhao-view-bottom-b" @click="goSift">
						确定
					</view>
				</view>
				
			</view>
		</view> -->
	</view>
</template>

<script>
	import commonChoose from '@/pages/phone/common/commonChoose.vue'
	import verify from '@/pages/utils/verifyUtils.js'
	let app = ''
	export default {
		components: {
			commonChoose
		},
		data() {
			return {
				itemId:'',
				item:{},
				role:'',
				roleUrl:'',
				windowHeight: 0,
				needAdapt: false, //判断是不是苹果x以上机型
				linkMsg: false,
				kpMsg: false,
				zhankai: require('../../../../static/phone/zhankai.png'),
				shouqi: require('../../../../static/phone/shouqi.png'),
				
				
				
				showChoose: false,
				chooseResult: '',
				chooseList: [],
				chooseTag: "",
				
				customTypeList: [],//客户类型
				customType: '请选择客户类型',
				categoryDict:'',//value
				customTypeValue: -1,
				
				
				enrollType: "请选择注册类别",
				enrollTypeValue: -1,
				enrollTypeList: [],//注册类别
				permDict:'',
				
				address:'',
				// area: "请选择地区",
				// areaValue: -1,
				dataList: [],//绑定用户
				nameList: [],//常用律师
				
				
				teamTag:"请选择组别标签",
				teamTagValue:-1,
				teamTagList:[],//组别标签
				groupDict:'',//value
				
				
				remark:"",
				showSift:false,
				
				// area:'',
				// province:'',
				// city:'',
				// county:'',
				
				name:'',
				shortName:'',
				phoneNumber:'',
				faxNumber:'',
				email:'',
				website:'',
				contactName:'',
				companyName:'',
				taxNo:'',
				bankName:'',
				bankNo:'',
				regAddress:'',
				regPhone:'',
				remark:'',
				domicile:'',
				
				
				
				searchList:[],
				keywordLawyer:'',
				searchCustomerList:[],
				keywordCustomer:'',
			}
		},
		onLoad(options) {
			app = getApp()
			var _this = this
			_this.itemId = options.itemId
			// _this.item = JSON.parse(options.item)
			// console.log(_this.item)
			
			_this.needAdapt = app.globalData.needAdapt && app.globalData.isIPhone
			_this.role = app.globalData.role
			_this.roleUrl =  _this.$roleUrl({tab:_this.role})
			
			_this.getDetail()
			
			if (_this.needAdapt) {
				_this.windowHeight = (app.globalData.windowHeight - 88) * 2 + 'rpx'
			} else {
				_this.windowHeight = (app.globalData.windowHeight - 54) * 2 + 'rpx'
			}
			
			setTimeout(function(){
				//客户类型
				_this.getCustomer_type()
				//权限类别
				_this.getCustomer_perm()
				//组别标签
				_this.getCustomer_group()
			},500)
			
		},
		onShow() {

		},
		mounted() {

		},
		methods: {
			
			async getDetail(){
				let _this = this
				uni.showToast({
					title:'获取详情...',
					icon:'loading'
				})
				const res = await _this.$myRequest({
					url:`/${_this.roleUrl}/customer/${_this.itemId}`,
				})
				uni.hideLoading()
				
				console.log('详情',res)
				if(res.data.code==200){
					_this.item = res.data.data
					_this.setData(_this.item)
				}else{
					uni.showToast({
						title:'暂无数据',
						icon:'none'
					})
				}
								
			},
			
			setData(data){
				let _this = this
				_this.name = data.name
				_this.shortName= data.shortName
				// _this.area = data.province+' '+data.city+' '+data.county
				// _this.province = data.province
				// _this.city = data.city
				// _this.county = data.county
				
				_this.address = data.address
				
				_this.phoneNumber= data.phoneNumber
				_this.faxNumber= data.faxNumber
				_this.email= data.email
				_this.website= data.website
				_this.contactName= data.contactName
				_this.domicile= data.domicile
				
				_this.companyName= data.companyName
				_this.taxNo= data.taxNo
				_this.bankName= data.bankName
				_this.bankNo= data.bankNo
				_this.regAddress= data.regAddress
				_this.regPhone= data.regPhone
				_this.remark= data.remark
				
				
				let users = data.users
				let staff = data.staff
				for (var i = 0; i < users.length; i++) {
					users[i]['id'] = users[i]['userId']
					let avatarPic = users[i]['account']['avatarPic']
					if(avatarPic!=undefined && avatarPic.indexOf('http')<0){
						avatarPic = this.$imageUrls({picUrls: avatarPic})
						users[i]['account']['avatarPic'] = avatarPic
					}
					_this.dataList.push(users[i])
				}
				
				for (var i = 0; i < staff.length; i++) {
					staff[i]['id'] = staff[i]['userId']
					let avatarPic = staff[i]['account']['avatarPic']
					if(avatarPic!=undefined && avatarPic.indexOf('http')<0){
						avatarPic = this.$imageUrls({picUrls: avatarPic})
						staff[i]['account']['avatarPic'] = avatarPic
					}
					_this.nameList.push(staff[i])
				}
				
			},
			
			/**
			 * 点击了确定
			 */
			saveIt() {
				let _this = this
				console.log('保存')
				if(!verify.isNotEmpty(_this.name)){
					_this.showToastEmpty('客户名称')
					return
				}
				// if(!verify.isNotEmpty(_this.shortName)){
				// 	_this.showToastEmpty('客户简称')
				// 	return
				// }
				if(!verify.isNotEmpty(_this.categoryDict)){
					_this.showToastEmpty('客户类型')
					return
				}
				// if(!verify.isNotEmpty(_this.area)){
				// 	_this.showToastEmpty('联系地址')
				// 	return
				// }
				if(!verify.isNotEmpty(_this.address)){
					_this.showToastEmpty('联系地址')
					return
				}
				if(_this.dataList.length==0){
					_this.showToastEmpty('绑定用户')
					return
				}
				
				_this.saveIt()
			
			},
			
			//提交接口
			async saveIt(){
				let _this = this
				uni.showToast({
					title:'正在提交...',
					icon:'loading'
				})
				
				let data={
					id:_this.itemId,
					name:_this.name,
					shortName:_this.shortName,
					categoryDict:_this.categoryDict,
					// province:_this.province,
					// city:_this.city,
					// county:_this.county,
					address:_this.address,
					domicile:_this.domicile,
					phoneNumber:_this.phoneNumber,
					faxNumber:_this.faxNumber,
					email:_this.email,
					website:_this.website,
					contactName:_this.contactName,
					companyName:_this.companyName,
					taxNo:_this.taxNo,
					bankName:_this.bankName,
					bankNo:_this.bankNo,
					regAddress:_this.regAddress,
					regPhone:_this.regPhone,
					permDict:_this.permDict,
					groupDict:_this.groupDict,
					remark:_this.remark
					
				}
				
				
				
				if(_this.dataList.length>0){
					let userIds = []
					let authorizeUserIds = []
					for (var i = 0; i < _this.dataList.length; i++) {
						userIds.push(_this.dataList[i]['id'])
						
						if(_this.dataList[i]['isAuthorize']['desc']==='是'){
							authorizeUserIds.push(_this.dataList[i]['id'])
						}
					}
					
					_this.$set(data, 'userIds', userIds);
					_this.$set(data, 'authorizeUserIds', authorizeUserIds);
				}
				
				if(_this.nameList.length>0){
					let staffIds = []
					for (var i = 0; i < _this.nameList.length; i++) {
						staffIds.push(_this.nameList[i]['id'])
					}
					

					_this.$set(data, 'staffIds', staffIds);
			
				}
				
				
				
				const res = await _this.$myRequest({
					url:`/${_this.roleUrl}/customer`,
					method:'PUT',
					data:data
				})
				uni.hideLoading()
				console.log('提交结果',res)
				if(res.data.code==200){
					uni.showToast({
						title:'提交成功',
						icon:'success',
						duration:2000
					})
					setTimeout(function(){
						uni.navigateBack({
							delta:-1
						})
					},2000)
				}
			},
			
			/**
			 * 律师
			 */
			searchLawyer(val){
				console.log(val)
				let _this = this
				let code = val.detail.value
				//查询律师选择器
				_this.getLawyerNameList(code)
			},
			async getLawyerNameList(code){
				console.log(code)
				let _this = this
				const res = await _this.$myRequest({
					url: `/${_this.roleUrl}/lawyer/selector`,
					data: {
						keyword:code,
						// size: 1000,
						// page: 1
					},
					method: 'POST', //默认是GET
				})
				console.log('律师', res)
				_this.searchList = []
				if (res.data.code == 200) {
					let list = res.data.data
					for (var i = 0; i < list.length; i++) {
						let avatarPic = list[i]['account']['avatarPic']
						if(avatarPic!=undefined && avatarPic.indexOf('http')<0){
							avatarPic = this.$imageUrls({picUrls: avatarPic})
							list[i]['account']['avatarPic'] = avatarPic
						}
					}
					
					
					_this.searchList = list
				}
			},
			//选择
			clickLawyer(item){
				let _this = this
				for (var i = 0; i < _this.nameList.length; i++) {
					if(item.account.id == _this.nameList[i]['account'].id){
						uni.showToast({
							title:'当前律师已存在!',
							icon:'none'
						})
						
						return
					}
				}
				
				this.nameList.push(item)
				this.searchList = []
				this.keywordLawyer = ''
			},
			
			/**
			 * 绑定用户
			 */
			searchCustomer(val){
				console.log(val)
				let _this = this
				let code = val.detail.value
				//查询律师选择器
				_this.getCustomerNameList(code)
			},
			async getCustomerNameList(code){
				let _this = this
				const res = await _this.$myRequest({
					url: `/${_this.roleUrl}/commUser/selector/0`,
					data: {
						keyword:code,
						// size: 1000,
						// page: 1
					},
					method: 'POST', //默认是GET
				})
				// console.log('用户', res)
				_this.searchCustomerList = []
				if (res.data.code == 200) {
					let list = res.data.data
					for (var i = 0; i < list.length; i++) {
						let avatarPic = list[i]['account']['avatarPic']
						if(avatarPic!=undefined && avatarPic.indexOf('http')<0){
							avatarPic = this.$imageUrls({picUrls: avatarPic})
							list[i]['account']['avatarPic'] = avatarPic
						}
					}
					
					_this.searchCustomerList = list
				}
			},
			clickCustomer(item){
				let _this = this
				for (var i = 0; i < _this.dataList.length; i++) {
					if(item.account.id == _this.dataList[i]['account'].id){
						uni.showToast({
							title:'当前用户已存在!',
							icon:'none'
						})
						
						return
					}
				}
				
				item.isAuthorize={
					"desc":"否",
					"code":"0"
				}
				this.dataList.push(item)
				this.searchCustomerList = []
				this.keywordCustomer = ''
			},
			
			//客户类型
			async getCustomer_type(){
				let _this = this
				const res = await _this.$myRequest({
					url: "/comm/dict/list/param_customer_type",
				})
				console.log('客户类型',res)
				if(res.data.code==200){
					let list = res.data.data
					_this.customTypeList = list
					
					for (var i = 0; i < list.length; i++) {
						if(_this.item.categoryDict == list[i]['value']){
							_this.customType = list[i]['name']
							_this.categoryDict = _this.item.categoryDict
						}
					}
				}
			},
			//权限类别
			async getCustomer_perm(){
				let _this = this
				const res = await _this.$myRequest({
					url: "/comm/dict/list/param_customer_perm",
				})
				console.log('权限类别',res)
				if(res.data.code==200){
					let list = res.data.data
					
					_this.enrollTypeList = list
					
					for (var i = 0; i < list.length; i++) {
						if(_this.item.permDict == list[i]['value']){
							_this.enrollType = list[i]['name']
							_this.permDict = _this.item.permDict
						}
					}
				}
			},
			//组别标签
			async getCustomer_group(){
				let _this = this
				const res = await _this.$myRequest({
					url: "/comm/dict/list/param_customer_group",
				})
				console.log('组别标签',res)
				if(res.data.code==200){
					let list = res.data.data
					
					_this.teamTagList = list
					
					for (var i = 0; i < list.length; i++) {
						if(_this.item.groupDict == list[i]['value']){
							_this.teamTag = list[i]['name']
							_this.groupDict = _this.item.groupDict
						}
					}
				}
			},
			

			/**
			 * 选择客户类型 弹窗
			 */
			chooseCustomType() {
				let _this = this
				_this.chooseTag = 'customType'
				_this.chooseList = _this.customTypeList
				_this.chooseResult = _this.categoryDict
				_this.$nextTick(() => {
					_this.showChoose = true
				})

			},
			/**
			 * @param {Object} 选择注册类别
			 */
			chooseEnrollType() {
				let _this = this
				_this.chooseTag = 'enroll'
				_this.chooseList = _this.enrollTypeList
				_this.chooseResult = _this.permDict
				_this.$nextTick(() => {
					_this.showChoose = true
				})

			},
			
			/**
			 * 选择组别标签
			 */
			chooseTeamTag(){
				// this.showSift = true
				let _this = this
				_this.chooseTag = 'team'
				_this.chooseList = _this.teamTagList
				_this.chooseResult = _this.groupDict
				_this.$nextTick(() => {
					_this.showChoose = true
				})
				
			},
			

			/**
			 * 选择后赋值
			 */
			gotIt(val) {
				console.log(val)
				let _this = this
				_this.showChoose = false
				let tag = val.split(";")[0]
				let index = val.split(";")[1]
				if (tag == 'customType') {
					_this.categoryDict = _this.customTypeList[index]['value']
					_this.customType = _this.customTypeList[index]['name']
					_this.customTypeValue = _this.customTypeList[index]['id']
				} else if (tag == 'enroll') {
					_this.permDict = _this.enrollTypeList[index]['value']
					_this.enrollType = _this.enrollTypeList[index]['name']
					_this.enrollTypeValue = _this.enrollTypeList[index]['id']
				}else if(tag == 'team'){
					_this.groupDict = _this.teamTagList[index]['value']
					_this.teamTag = _this.teamTagList[index]['name']
					_this.teamTagValue = _this.teamTagList[index]['id']
				}
			},
			/**
			 * 省市区选择
			 */
			// bindRegionChange(val) {
			// 	console.log(val)
			// 	let _this = this
			// 	_this.area = val.detail.value[0] + ' ' + val.detail.value[1] + ' ' + val.detail.value[2]
			// 	_this.areaValue = val.detail.code[0]
				
			// 	_this.province = val.detail.value[0]
			// 	_this.city = val.detail.value[1]
			// 	_this.county = val.detail.value[2]
				
			// },
			
			/**
			 * 点击了取消
			 */
			cancelIt(){
				uni.navigateBack({
					delta:-1
				})
			},
			/**
			 * 联系信息展开收起
			 */
			openClose() {
				this.linkMsg = !this.linkMsg
			},
			/**
			 * 开票信息展开收起
			 */
			openCloseKp() {
				this.kpMsg = !this.kpMsg
			},
			
			/**
			 * 删除绑定用户
			 */
			deleteBind(item, index){
				this.dataList.splice(index, 1)
			},


			/**
			 * 删除常用律师
			 */
			deleteLayer(item, index) {
				this.nameList.splice(index, 1)
			},
			
			/**
			 * 授权/取消授权
			 */
			toAuth(index){
				let _this = this
				console.log('授权',index)
				var item = _this.dataList[index];
				
				if(item['isAuthorize']['desc'] === "是"){
					item['isAuthorize']['desc'] = "否"
					item['isAuthorize']['code'] = "0"
				}else{
					item['isAuthorize']['desc'] = "是"
					item['isAuthorize']['code'] = "1"
				}
				
				
				_this.dataList.splice(index, 1, item);
				
				
	
			},
			
			
			showToastEmpty(val){
				uni.showToast({
					title:`${val}不能为空！`,
					icon:'none'
				})
			},
			
			/**
			 * 数据校验
			 */
			
			
			
			
			/**
			 * @param {Object} 组别标签
			 */
			// siftTeamTag(index){
			// 	let _this = this
			// 	_this.teamTagList[index]['sel'] = !_this.teamTagList[index]['sel']
			// },
			/**
			 * 获取筛选结果
			 */
			// goSift(){
			// 	let _this = this
			// 	_this.showSift = false
				
			// 	for (var i = 0; i < _this.teamTagList.length; i++) {
			// 		if(_this.teamTagList[i]['sel']){
			// 			console.log(_this.teamTagList[i]['name'])
			// 		}
			// 	}
				
			// },
			
			/**
			 * 重置筛选
			 */
			// cancelSift(){
			// 	let _this = this
				
			// 	for (var i = 0; i < _this.teamTagList.length; i++) {
			// 		_this.teamTagList[i]['sel'] = false
					
			// 	}
			// },
		}
	}
</script>

<style>
	page {
		background-color: #f7f7f7;
	}
</style>
<style lang="scss" scoped>
	.view-bottom {
		position: fixed;
		width: 100%;
		bottom: 0;
		background-color: #ffffff;
		border-top: 1rpx solid #e1e1e1;
		padding-bottom: env(safe-area-inset-bottom);
	}

	.view-bottom-s {
		height: 108rpx;
		display: flex;
		align-items: center;
	}

	.view-bottom-sl {
		width: 260rpx;
		height: 88rpx;
		border-radius: 44rpx;
		border: 1px solid #2DA9C5;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 32rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: #2DA9C5;
		margin-left: 32rpx;
	}

	.view-bottom-sr {
		width: 394rpx;
		height: 88rpx;
		background: #2DA9C5;
		border-radius: 58rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 32rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: #ffffff;
		margin-left: 32rpx;
	}

	.title {
		font-size: 28rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 550;
		color: #333333;
	}

	.star {
		color: #FF6132;
	}

	.line {
		height: 1rpx;
		background-color: #eeeeee;
	}

	.line2 {
		height: 24rpx;
		background-color: #f7f7f7;
	}

	.placeholder-view {
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #333333;
		margin-left: auto;
		text-align: right;
		width: 500rpx;
	}

	.open-close {
		font-size: 24rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #2DA9C5;
	}

	.xuanze {
		margin-left: auto;
		display: flex;
		align-items: center;
	}

	.xuanze-t {
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #888888;
		margin-right: 5rpx;
	}

	.xuanze-tt {
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #333333;
		margin-right: 5rpx;
	}

	.xuanze-i {
		width: 12rpx;
		height: 24rpx;
	}

	.listview {
		display: flex;
		flex-wrap: wrap;
		padding-bottom: 32rpx;

	}


	.main_item {
		width: 336rpx;
		height: 88rpx;
		background: #E8F7FB;
		border-radius: 8rpx;
		display: flex;
		align-items: center;
		margin-top: 16rpx;
	}

	.main_item2 {
		width: 336rpx;
		height: 88rpx;
		background: #E8F7FB;
		border-radius: 8rpx;
		display: flex;
		align-items: center;
		margin-top: 16rpx;
		margin-left: 14rpx;
	}

	.listview-name {
		font-size: 24rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #666666;
	}
	
	.isauth{
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #999999;
		margin-left: 32rpx;
	}
	.shuline{
		margin-left: 32rpx;
		width: 3rpx;
		height: 28rpx;
		background: #2DA9C5;
	}
	.isauth2{
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 600;
		color: #2DA9C5;
		margin-left: 32rpx;
	}
	
	.textareaview{
		width: 686rpx;
		height: 280rpx;
		border-radius: 4rpx;
		background-color: #ffffff;
		margin-top: 12rpx;
		border: 1rpx dashed #eeeeee;
	}
	
	.textarea{
		padding-left: 32rpx;
		padding-right: 32rpx;
		padding-top: 24rpx;
		padding-bottom: 24rpx;
		font-size: 28rpx;
		color: #333333;
		line-height: 20rpx;
		width: 490rpx;
		height: 232rpx;
	}
	
	.zhezhao {
		width: 100%;
		height: 100vh;
		background: rgba(0, 0, 0, 0.4);
		z-index: 9999;
		position: fixed;
		left: 0;
		top: 0;
		overflow: scroll;	
		// padding-top: 10vh;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.zhezhao-view-bottom{
		position: fixed;
		width: 100%;
		bottom: 0;
		background-color: #ffffff;
		border-radius: 8px 8px 0px 0px;
		
	}
	.zhezhao-view-bottom-s{
		height: 108rpx;
		display: flex;
		align-items: center;
		border-top: 1rpx #eeeeee solid;
		background-color: #ffffff;
		padding-bottom: env(safe-area-inset-bottom); // 适配iphoneX的底部
	}
	.zhezhao-view-bottom-c{
		width: 260rpx;
		height: 88rpx;
		border-radius: 44rpx;
		border: 1px solid #2DA9C5;
		margin-left: 32rpx;
		font-size: 32rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: #2DA9C5;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.zhezhao-view-bottom-b{
		width: 394rpx;
		height: 88rpx;
		background: #2DA9C5;
		border-radius: 58rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 36rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: #E8F7FB;
		line-height: 50rpx;
		margin-left: 32rpx;
	}	
	.zhezhao-title-view{
		height: 114rpx;
		display: flex;
		align-items: center;
		padding-left: 32rpx;
		font-size: 36rpx;
		font-family: PingFangSC-Semibold, PingFang SC;
		font-weight: 600;
		color: #333333;
	}
	.sift-listview{
		display: flex;
		flex-wrap: wrap;
	}
	.sift-item{
		width: 212rpx;
		height: 72rpx;
		background: #F7F7F7;
		border-radius: 8rpx;
		font-size: 28rpx;
		font-family: PingFangSC-Semibold, PingFang SC;
		font-weight: 400;
		color: #18252C;
		display: flex;
		align-items: center;
		justify-content: center;
		margin-left: 26rpx;
		margin-bottom: 32rpx;
	}
	.sift-item-foucs{
		width: 212rpx;
		height: 72rpx;
		background: #E8F7FB;
		border-radius: 8rpx;
		font-size: 28rpx;
		font-family: PingFangSC-Semibold, PingFang SC;
		font-weight: 600;
		color: #2DA9C5;
		display: flex;
		align-items: center;
		justify-content: center;
		margin-left: 26rpx;
		margin-bottom: 32rpx;
	}
	
	
	.laywer-sel-popup{
		height: 330rpx;
		width: 686rpx;
		background: #FFFFFF;
		box-shadow: 0px 2px 8px 0px rgba(0,0,0,0.2);
		border-radius: 2px;
	}
</style>
